#!/bin/bash -e

function info() {
echo Usage: `basename $0` snp.vcf indel.vcf
exit 65
}

while getopts  ":i:p:G" opts
do
        case  $opts  in
        i) intervals=$OPTARG;;
		p) out_prefix=$OPTARG;;
		G) somatic=true;;
		*) info;;
        esac
done
shift $(($OPTIND - 1))

if test -z "$2"; then info; fi


. /mnt/ilustre/app/medical/tools/.var
# nprot filter

# echo gatk SelectVariants snp
# java $tmp -jar $gatk \
# -R $ref_genome \
# -T SelectVariants \
# -V $1 \
# -o $out_prefix.snp.nprot.vcf \
# -selectType SNP

# echo gatk SelectVariants indel
# java $tmp -jar $gatk \
# -R $ref_genome \
# -T SelectVariants \
# -V $1 \
# -o $out_prefix.indel.nprot.vcf \
# -selectType INDEL

filter_clustered_mutations.pl $1 $2

echo;echo;echo gatk CombineVariants
java $tmp -jar $gatk \
	-R $ref_genome \
	-T CombineVariants \
	--variant $1.cluster_filtered.vcf \
	--variant $2.cluster_filtered.vcf \
	-o $out_prefix.nprot.high.vcf \
	-genotypeMergeOptions UNSORTED
	
	
echo;echo;echo gatk CombineVariants
java $tmp -jar $gatk \
	-R $ref_genome \
	-T CombineVariants \
	--variant $1.cluster_drop.vcf \
	--variant $2.cluster_drop.vcf \
	-o $out_prefix.nprot.drop.vcf \
	-genotypeMergeOptions UNSORTED

format_filter_vcf.pl $out_prefix.nprot.drop.vcf nprot_cluster "nprot_cluster filter" > $out_prefix.nprot.low.vcf

mv -f $out_prefix.nprot.drop.vcf .$out_prefix.nprot.drop.vcf

. $cmd_done